<!DOCTYPE html>
<html>
<head lang="zh-CN">
    <meta charset="UTF-8">
    <!--以最新的IE浏览器引擎去渲染-->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <!--如果是双核浏览器，则使用webkit内核渲染-->
    <meta name="renderer" content="webkit"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <title></title>
    <meta name="description" content=""/>
    <meta name="keyword" content=""/>
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico"/>
    <link rel="stylesheet" href="__PUBLIC__/frame/layui/css/layui.css">
    <link rel="stylesheet" href="__PUBLIC__/frame/static/css/style.css">
    <link rel="stylesheet" href="__PUBLIC__/css/H-ui.admin.css">
    <link rel="stylesheet" href="__PUBLIC__/css/H-ui.min.css">

    <link rel="icon" href="__PUBLIC__/frame/static/image/code.png">
</head>
<body>
<div class="layui-fluid" style="margin-top: 20px">
    <article class="page-container">
        <form class="form form-horizontal" id="form-admin-add" method="post" action="">
            <input type="hidden" name="id" value="{$AdminData.id}">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>管理员名称：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="{$AdminData.username}" placeholder="" id="adminName" name="username">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>真实姓名：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="{$AdminData.realname}" placeholder="" id="realname" name="realname">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>初始密码：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="password" class="input-text" autocomplete="off" value="" placeholder="密码" id="password" name="password">
                    <p style="color: red;">如果不填写密码,表示不修改密码</p>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>确认密码：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="password" class="input-text" autocomplete="off"  placeholder="确认新密码" id="password2" name="password2">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>性别：</label>
                <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                    <div class="radio-box">
                        <input name="gender" <?php echo ($AdminData['gender']==1)?'checked':''?> type="radio" id="sex-1" checked value="1">
                        <label for="sex-1">男</label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" <?php echo ($AdminData['gender']==0)?'checked':''?> id="sex-2" name="gender" value="0">
                        <label for="sex-2">女</label>
                    </div>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="{$AdminData.phonenumber}" placeholder="" id="phone" name="phonenumber">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>邮箱：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" placeholder="@" name="email" id="email" value="{$AdminData.email}">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">所在角色：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <?php foreach($roleData as $k => $v){?>
                    <?php if(in_array($v['id'],$rid)){
                            $check = 'checked="checked"';}else{
                            $check = '';
                            }
                    ?>
                    <label><input <?php echo $check;?> type="checkbox" name="role_id[]" value="<?php echo $v['id']; ?>"><?php echo $v['role_name']?>
                        &nbsp;&nbsp;</label>
                    <?php }?>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是否启用：</label>
                <div class="formControls col-xs-8 col-sm-9 skin-minimal">

                    <div class="radio-box">
                        <label><input name="is_use" type="radio" <?php echo $AdminData['is_use']==1?'checked':''?> value="1">
                            启用</label>
                    </div>

                    <div class="radio-box">
                        <label><input type="radio" <?php echo $AdminData['is_use']==0?'checked':''?> id="" name="is_use" value="0">
                            禁用</label>
                    </div>

                </div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input id="tijiao" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                </div>
            </div>
        </form>
    </article>
</div>
</body>
<script type="text/javascript" src="__PUBLIC__/frame/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['form', 'layer'], function () {
        // 操作对象
        var form = layui.form
            , layer = layui.layer
            , $ = layui.jquery;

        $("#tijiao").click(function () {
            $.post("/index.php/home/admin/edit", $('form').serialize(),
                function(result){
                    if(result.status == '0'){
                        layer.alert(result.message);
                    }
                    if(result.status == '1'){
                        layer.open({
                            content:result.message,
                            icon:1,
                            yes:function(){
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.$('.refresh').click();  //添加成功获取一下数据
                                parent.layer.close(index); //再执行关闭
                            }
                        });
                    }
                },
                "JSON");
        })

    })
</script>